Utils.UI = {};

/*
 *  Utils.UI.Tweet
*/
Utils.UI.Tweet = function(w, time, list)
{
    if(list){
      time = 'list';
    }
    var user = w.user.screen_name,
    nome = w.user.name,
    classic_txt = escape(w.text),
    txt = w.retweeted_status ? w.retweeted_status.text : w.text,
    foto = w.user.profile_image_url,
    data = w.created_at,
    source = w.source,
    tid =  w.id;
    tid_ = w.id;
    read = w.read ? 'read' : 'unread';

    var in_reply = w.in_reply_to_status_id ? '<a id="in_reply_to_'+tid+'" class="cinza p8" href="#" nohref="'+tURL(w.in_reply_to_screen_name+'/status/'+w.in_reply_to_status_id)+'" onclick="Interface.Tweet.getConversation('+tid+', '+w.in_reply_to_status_id+', \''+time+'\')" title="'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'">'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'</a>' : '';
    var Retweeted = '';
    var RT  = '<a onclick="Retweet('+tid+', \''+time+'\');" class="opts fr" title="'+Traduz('retweet')+'">'+Traduz('retweet')+'</a>';
    var Mentionado = (txt.indexOf('@'+db.pega('user')) != -1) ? ( time == "home" ? "mentionado" : "") : "";
    var del = db.pega('user') == user ? '<img id="deleta_load_'+tid+'" class="dn fr" /><span class="opts fr"><a id="deleta_button_'+tid+'" onclick="Deleta('+tid+', \''+time+'\');" class="lixo" title="'+Traduz('delete')+'">'+Traduz('delete')+'</a></span>' : '';
    var GEO = '';

    var proct = '';
    if(w.user.protected){
      proct  = '<span class="cadeado" title="Protected"></span> ';
    }

    if(w.retweeted_by_me){
      var rt_user = db.pega('user');
      Retweeted = '<span id="retweeted_status_'+tid+'"><br /><span class="cinza p8" title="'+Traduz('retweeted_by')+' '+rt_user+'">'+Traduz('retweeted_by')+' </span><span id="retweeted_status_by_me_'+tid+'"><a class="reter p8" nohref="'+tURL(rt_user)+'" onclick="ShowUser(\''+rt_user+'\')" title="'+rt_user+'">'+Traduz('you')+'</a></span></span>';
      RT  = '<a onclick="Deleta('+tid+', \''+time+'\', '+w.retweeted_by_me_status+');" class="opts fr" title="'+Traduz('undo_retweet')+'">'+Traduz('undo_retweet')+'</a>';
    }

    if(w.retweeted_status){
      rt_user = w.user.screen_name;
      rt_user_ = rt_user;

      user = w.retweeted_status.user.screen_name;
      nome = w.retweeted_status.user.name;
      txt = w.retweeted_status.text;
      foto = w.retweeted_status.user.profile_image_url;
      data = w.retweeted_status.created_at;
      source = w.retweeted_status.source;
    //    tid = w.retweeted_status.id;
      tid = w.id;
      tid_ = w.retweeted_status.id;
      RT = '<a onclick="RetweetRT('+tid+', \''+time+'\');" class="opts fr" title="'+Traduz('retweet')+'">'+Traduz('retweet')+'</a>';

      in_reply = w.retweeted_status.in_reply_to_status_id ?
      '<a id="in_reply_to_'+tid+'" class="cinza p8" href="#" nohref="'+tURL(w.retweeted_status.in_reply_to_screen_name+'/status/'+w.retweeted_status.in_reply_to_status_id)+'" onclick="Interface.Tweet.getConversation('+tid+', '+w.retweeted_status.in_reply_to_status_id+', \''+time+'\')" title="'+Traduz('in_reply_to')+' '+w.retweeted_status.in_reply_to_screen_name+'">'+Traduz('in_reply_to')+' '+w.retweeted_status.in_reply_to_screen_name+'</a>'
      : '';

      txt = '<span class="rts" title="'+Traduz('retweeted_by')+' '+rt_user+'">Retweeted</span> <a class="reter" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+user+'</a> '+txt;
      Retweeted = '<span id="retweeted_status_'+tid+'"><br /><span class="cinza p8" title="'+Traduz('retweeted_by')+' '+rt_user+'">'+Traduz('retweeted_by')+' </span><span id="retweeted_status_by_other_'+tid+'"><a class="reter p8" nohref="'+tURL(rt_user)+'" onclick="ShowUser(\''+rt_user+'\')" title="'+rt_user+'">'+rt_user_+'</a></span';
      if(w.retweeted_by_me){
        var rt_user = db.pega('user');
        Retweeted += '<span id="retweeted_status_by_me_'+tid+'">, <a class="reter p8" nohref="'+tURL(rt_user)+'" onclick="ShowUser(\''+rt_user+'\')" title="'+rt_user+'">'+Traduz('you')+'</a></span></span>';
        RT  = '<a onclick="Deleta('+tid+', \''+time+'\', '+w.retweeted_by_me_status+');" class="opts fr" title="'+Traduz('undo_retweet')+'">'+Traduz('undo_retweet')+'</a>';
      }else{
        Retweeted += '</span>';
      }
      Retweeted += ' <span class="opts2">(<span class="cinza p8 tweetdata" data="'+w.created_at+'"></span>)</span>';

    }

    RT = db.pega('user') == user ? '' : RT;

    var fav = w.favorited ? '<a id="tweet_fav_'+tid+'" class="star" fav="true" onclick="UnFavorite('+tid+', \''+time+'\')" title="'+Traduz('unfavorite')+'">'+Traduz('unfavorite')+'</a><img id="tweet_ifav_'+tid+'" src="" class="dn" />' :
                        '<a id="tweet_fav_'+tid+'" class="star opts" onclick="Favorite('+tid+', \''+time+'\')" title="'+Traduz('favorite')+'">'+Traduz('favorite')+'</a><img id="tweet_ifav_'+tid+'" src="" class="dn" />';

    var dm = db.pega('user') == user ? '' : '<a class="msg opts" onclick="ReplyDM('+tid+', \''+time+'\', true)" title="DM '+Traduz('to')+' '+user+'">'+Traduz('messages')+'</a>';

    txt = Utils.Regex.Replace(txt);

    txt = txt.replace('>@'+db.pega('user'), ' class="usuario photo bold">@'+db.pega('user'));

    w.html_tweet = txt;
    source = source.replace('rel=\"nofollow\"', 'class="cinza p8 source" onclick="Link(this, event);"');
    source = source.replace('href=', 'href="#" nohref=');
    var careator = !w.retweeted_status ?
                      '<a title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+
                          '<span class="creator">'+user+'</span>'+
                      '</a><br />' : '';
    var creator = '';

    if(w.reply_backup){
        var reply_backup = w.reply_backup;
        var cdn = 'dn'
    }else{
        var reply_backup = '';
        var cdn = 'dn';
    }

    if(w.replied && config.phantom_replies === "true")
    {
        var replied = 'replied';
    }else
    {
        var replied = '';
    }

    GEO = Utils.Tweet.GetGeo(w, tid, time);

    r =
    '<div id="tweply_'+tid+'" class="tweply">' +
              '<div class="twet '+read+' '+Mentionado+' '+replied+' ">' +
                  '<div class="text">' +
                      '<input id="user_'+tid+'" value="'+user+'" type="hidden" />' +
                      '<a title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')" class="fl">' +
                        '<img class="photo" src="'+foto+'" width="45" height="45" />' +
                      '</a>' +
                      creator+
                      '<div class="fr">'+
                          fav+
                          dm+
                          '<a title="'+Traduz('translate_this_tweet')+'" onclick="Traduzir('+tid+', \''+time+'\');" class="trans opts">.</a>'+
                      '</div>'+
    			(!w.retweeted_status ? '<span class="tweets_names dn" >'+proct+'<a class="usuario" title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+user+'</a>: </span>':'')+
                      '<span id="texto_'+tid+'" class="texwt" data="'+classic_txt+'" html="'+escape(txt)+'">'+txt+'</span>' +
                  '</div>' +
                  '<div class="cinza">' +
                      '<span>'+GEO+'<a title="'+tid+'" class="cinza p8 tweetdata" href="#" nohref="'+tURL(user+'/status/'+tid_)+'" onclick="Link(this, event);" data="'+data+'"></a></span>' +
                      '<span id="data_rt_'+tid+'">'+
                          ' <span class="cinza p8">'+Traduz('from')+'</span> '+source+' ' +
                          in_reply +
      					Retweeted +
                      '</span>'+
                      '<span id="data_retweet_'+tid+'">'+
                          RT +
                          del +
                      '</span>'+
                  '</div>' +
                  '<a tid="'+tid+'" time="'+time+'" onclick="Reply('+tid+', false, \''+time+'\');" class="r click_to_reply" title="'+Traduz('reply')+' '+user+'">'+Traduz('reply')+'</a>' +
              '</div>' +

              '<div id="reply_'+tid+'" class="reply '+cdn+'">' +
                '<textarea onkeydown="Atalho(event, '+tid+', \''+time+'\')" onkeyup="Count('+tid+', \''+time+'\')" id="reply_text_'+tid+'" class="p10" backup="'+reply_backup+'"></textarea><br/>' +
                '<span id="retweet_choice_'+tid+'" class="dn">' +
                    '<br />'+
                    '<button class="button_margin" id="rt_now_'+tid+'" onclick="RetweetOficial('+tid+', \''+time+'\')" title="'+Traduz('retweet_now')+'">'+Traduz('retweet_now')+'</button>' +
                    '<button class="button_margin" id="edit_rt_'+tid+'" onclick="RetweetEdit('+tid+', \''+time+'\');" title="'+Traduz('edit')+'">'+Traduz('edit')+'</button>' +
                    '<a onclick="ReplyCancel('+tid+', \''+time+'\')" class="p8" title="'+Traduz('cancel')+'">'+Traduz('cancel')+'</a>' +
                '</span>' +
                '<span id="reply_rt_'+tid+'" class="dn">' +
                   '<button title="'+Traduz('special_chars')+'" class="button fl bt_char" onclick="SpecialChars.show(\''+tid+'\', \''+time+'\');">&hellip;</button>'+
                   '<span class="short" title="'+Traduz('url_shortener')+'"><button onclick="ShortLink('+tid+', \''+time+'\')"  class="button fl"><img src="img/link.png" height="16" /></button><input onfocus="ShowShortLink('+tid+', \''+time+'\')" _onblur="HideShortLink('+tid+')" active="false" class="short_link_url fl" id="short_link_url_'+tid+'" type="text" /></span><br class="cb"/>' +
                   '<button class="button_margin" id="botao_'+tid+'" onclick="doReply('+tid+', \''+time+'\');" title="'+Traduz('done')+' (Enter)">'+Traduz('done')+'</button>' +
                   '<a id="botao_'+tid+'_cancel" onclick="ReplyCancel('+tid+', \''+time+'\')" title="'+Traduz('cancel')+'" class="p8">'+Traduz('cancel')+'</a>' +
                '</span>' +
                '<span id="count_'+tid+'" class="reply_left p13">140</span>' +
                '<span id="reply_status_'+tid+'" class="reply_left state"></span>' +
              '</div>' +
              '<div id="conversations_'+tid+'" class="conversations dn"></div>'+
      '</div>';
    return r;
}

/*
 *  Utils.UI.Conversation
*/
Utils.UI.Conversation = function(w, erro)
{
    if(erro)
    {
        var r =
        '<div class="tweply">' +
                  '<div class="twet">' +
                      '<div class="text" style="line-height:40px;vertical-align:middle;">' +
                            '<span class="texwt"><span class="cadeado"> </span>  '+erro+'</span>' +
                      '</div>' +
                  '</div>' +
        '</div>';
        return r;
    }
    var user = w.user.screen_name,
    nome = w.user.name,
    txt = w.text,
    foto = w.user.profile_image_url,
    data = w.created_at,
    source = w.source,
    tid =  w.id;

    var proct = '';
    if(w.user.protected){
      proct  = '<span class="cadeado"></span> ';
    }

    txt = Utils.Regex.Replace(txt);
    txt = txt.replace('>@'+db.pega('user'), ' class="usuario photo bold">@'+db.pega('user'));

    source = source.replace('rel=\"nofollow\"', 'class="cinza p8 source" onclick="Link(this, event);"');
    source = source.replace('href=', 'href="#" nohref=');

    var r =
    '<div id="conversation_'+tid+'" class="tweply">' +
              '<div class="twet">' +
                  '<div class="text">' +
                      '<a title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')" class="fl">' +
                        '<img class="photo" src="http://img.tweetimag.es/i/'+user+'_m" width="30" height="30" />' +
                      '</a>' +
                      proct+
    			      '<a class="usuario" title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+user+'</a>:'+
                      '<span class="texwt">'+txt+'</span>' +
                  '</div>' +
                  '<div class="cinza">'+
                      '<span><a title="'+tid+'" class="cinza p8 tweetdata" href="#" nohref="'+tURL(user+'/status/'+tid)+'" onclick="Link(this, event);" data="'+data+'"></a></span>' +
                      '<span id="data_rt_'+tid+'" class="p8">'+
                          ' <span class="cinza p8">'+Traduz('from')+'</span> '+source+' ' +
                      '</span>'+
                  '</div>' +
              '</div>' +
    '</div>';
    return r;
}

/*
 *  Utils.UI.Message
*/
Utils.UI.Message = function(w, time)
{
    var user = w.sender.screen_name,
    nome = w.sender.name,
    destino = w.recipient.screen_name;
    destinoNome = w.recipient.name;
    txt =  w.text,
    foto = w.sender.profile_image_url,
    data = w.created_at,
    tid = w.id;

    read = w.read ? 'read' : 'unread';
    if(w.reply_backup){
        var reply_backup = w.reply_backup;
    }else{
        var reply_backup = '';
    }

    txt = Utils.Regex.Replace(txt);

    r =
    '<div id="tweply_'+tid+'" class="tweply">' +
              '<div class="twet '+read+'">' +
                  '<div class="text">' +
                      '<input id="tid_'+tid+'" value="'+tid+'" type="hidden" />' +
                      '<input id="user_'+tid+'" value="'+user+'" type="hidden" />' +
                      '<input id="data_'+tid+'" value="'+data+'" type="hidden" />' +
                      '<a title="'+nome+' ('+user+')" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')" class="fl">' +
                        '<img class="photo" src="'+foto+'" width="45" height="45" />' +
                      '</a>' +
                      '<div class="fr">'+
                          '<a title="'+Traduz('translate_this_tweet')+'" onclick="Traduzir('+tid+', \''+time+'\');" class="trans opts">Hover</a>'+
                      '</div>'+
                      '<span title="'+nome+' ('+user+')" class="tweets_names dn" ><a class="usuario" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+user+'</a>: </span>'+
                      '<span id="texto_'+tid+'" class="texwt" data="'+escape(w.text)+'" html="'+escape(txt)+'">'+txt+'</span>' +
                  '</div>' +
                  '<div class="cinza">' +
                      '<span title="'+tid+'" class="cinza p8 tweetdata" data="'+data+'"></span>' +
                      ' '+Traduz('to').toLowerCase()+': <a class="usuario" title="'+destinoNome+'" href="#" nohref="'+tURL(user)+'" onclick="ShowUser(\''+destino+'\')">'+destino+'</a></span>'+
                      '<img id="deleta_load_'+tid+'" class="dn fr" /><span class="opts fr"><a id="deleta_button_'+tid+'" onclick="DeletaDM('+tid+', \''+time+'\');" class="lixo opts fr" title="'+Traduz('delete')+'">'+Traduz('delete')+'</a></span>' +
                  '</div>' +
                  '<a onclick="ReplyDM('+tid+', \''+time+'\', true);" class="r" title="'+Traduz('reply')+' '+user+'">'+Traduz('reply')+'</a>' +
              '</div>' +
              '<div id="reply_'+tid+'" class="reply dn dm">' +
                '<!--<div class="dm_title">'+
                  '<span class="dm_text">DM</span> '+
                  '<span class="dm_to">to</span> '+
                  '<span class="dm_user">ElinhoLeal</span'+
                '</div><br />-->'+
                '<textarea onkeydown="Atalho(evt, '+tid+', \''+time+'\')" onkeyup="Count('+tid+', \''+time+'\')" id="reply_text_'+tid+'" class="p8" backup="'+reply_backup+'"></textarea><br />' +
                '<span id="reply_rt_'+tid+'" class="dn">' +
                   '<button title="'+Traduz('special_chars')+'" class="button fl bt_char" onclick="SpecialChars.show(\''+tid+'\', \''+time+'\');">&hellip;</button>'+
                   '<span class="short" title="'+Traduz('url_shortener')+'"><button onclick="ShortLink('+tid+', \''+time+'\')"  class="button fl"><img src="img/link.png" height="16" /></button><input onfocus="ShowShortLink('+tid+', \''+time+'\')" _onblur="HideShortLink('+tid+')" active="false" class="short_link_url fl" id="short_link_url_'+tid+'" type="text" /></span><br class="cb"/>' +
                   '<button class="button_margin" id="botao_'+tid+'" onclick="doReplyDM('+tid+', \''+time+'\');" title="'+Traduz('done')+' (Enter)">'+Traduz('done')+'</button>' +
                   '<a onclick="ReplyCancel('+tid+', \''+time+'\')" title="'+Traduz('cancel')+'" class="p8">'+Traduz('cancel')+'</a>' +
                '</span>' +
                '<span id="count_'+tid+'" class="reply_left p13">140</span>' +
                '<span id="reply_status_'+tid+'" class="reply_left"></span>' +
              '</div>' +
      '</div>';
    return r;
}

/*
 *  Utils.UI.Page
*/
Utils.UI.Page = function(w, time)
{
    if(time == 'messages'){
        var user = w.sender.screen_name,
        nome = w.sender.name,
        classic_txt = '';
        txt =  w.text,
        foto = w.sender.profile_image_url,
        data = w.created_at,
        source = '',
        tid = w.id;
    }else{
        var user = w.user.screen_name,
        nome = w.user.name,
        classic_txt = w.retweeted_status ? w.text : '';
        txt = w.retweeted_status ? w.retweeted_status.text : w.text,
        foto = w.user.profile_image_url,
        data = w.created_at,
        source = w.source,
        tid = w.id;
    }


    read = w.read ? 'read' : 'unread';

    var in_reply = w.in_reply_to_status_id ? '<a class="cinza p8" href="'+tURL(w.in_reply_to_screen_name+'/status/'+w.in_reply_to_status_id)+'" target="_blank" title="'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'">'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'</a>' : '';
    var Retweeted = '';
    var RT  = '<a onclick="Retweet('+tid+', \''+time+'\');" class="opts fr" title="'+Traduz('retweet')+'">'+Traduz('retweet')+'</a>';

    if(w.retweeted_status){
      rt_user = w.user.screen_name;

      RT = db.pega('user') == user ? '' : RT;
      user = w.retweeted_status.user.screen_name;
      nome = w.retweeted_status.user.name;
      txt = w.retweeted_status.text;
      foto = w.retweeted_status.user.profile_image_url;
      data = w.retweeted_status.created_at;
      source = w.retweeted_status.source;
      tid = w.retweeted_status.id;
      in_reply = w.retweeted_status.in_reply_to_status_id ?
      '<a class="cinza p8" href="'+tURL(w.retweeted_status.in_reply_to_screen_name+'/status/'+w.retweeted_status.in_reply_to_status_id)+'" target="_blank" title="'+Traduz('in_reply_to')+' '+w.retweeted_status.in_reply_to_screen_name+'">'+Traduz('in_reply_to')+' '+w.retweeted_status.in_reply_to_screen_name+'</a>'
      : '';
      txt = '<span class="rts" title="'+Traduz('retweeted_by')+' '+rt_user+'">Retweeted</span> <a class="reter" href="'+tURL(user)+'" target="_blank"'+user+'</a> '+txt;
      Retweeted = '<br /><span class="cinza p8" title="'+Traduz('retweeted_by')+' '+rt_user+'">'+Traduz('retweeted_by')+' </span><a class="reter p8 user" href="'+tURL(rt_user)+'" target="_blank">'+rt_user+'</a>';
      Retweeted += ' <span class="opts2">(<span class="cinza p8 tweetdata" data="'+w.created_at+'">'+TweetData(w.created_at)+'</span>)</span>';
      RT = '<a onclick="RetweetRT('+tid+', \''+time+'\');" class="opts fr" title="'+Traduz('retweet')+'">'+Traduz('retweet')+'</a>';
    }

    var fav = w.favorited ? '<a id="tweet_fav_'+tid+'" class="star fr" fav="true" onclick="UnFavorite('+tid+', \''+time+'\')" title="'+Traduz('unfavorite')+'">'+Traduz('unfavorite')+'</a><img id="tweet_ifav_'+tid+'" src="" class="fr dn">' :
                        '<a id="tweet_fav_'+tid+'" class="star opts fr" onclick="Favorite('+tid+', \''+time+'\')" title="'+Traduz('favorite')+'">'+Traduz('favorite')+'</a><img id="tweet_ifav_'+tid+'" src="" class="fr dn">';

    var del = db.pega('user') == user ? '<a onclick="Deleta('+tid+', \''+time+'\');" class="lixo opts fr" title="'+Traduz('delete')+'">'+Traduz('delete')+'</a>' : '';

    txt = Utils.Regex.Replace(txt, true);

    source = source.replace('rel=\"nofollow\"', 'class="cinza p8 source" target="_blank"');
    var careator = !w.retweeted_status ?
                      '<a title="'+nome+'" nohref="'+tURL(user)+'" target="_blank">'+
                          '<span class="creator">'+user+'</span>'+
                      '</a><br />' : '';
    var creator = '';

    if(w.reply_backup){
      var reply_backup = w.reply_backup;
      //var reply_backup = '';
      var cdn = 'dn'
    }else{
      var reply_backup = '';
      var cdn = 'dn';
    }

    r =
    '<div id="tweply_'+tid+'" class="tweply" title="'+nome+' ('+user+')">' +
              '<div class="twet '+read+'">' +
                  '<div class="text">' +
                      '<input id="tid_'+tid+'" value="'+tid+'" type="hidden" />' +
                      '<input id="user_'+tid+'" value="'+user+'" type="hidden" />' +
                      '<input id="data_'+tid+'" value="'+data+'" type="hidden" />' +
                      '<a title="'+nome+'" href="'+tURL(user)+'" target="_blank" class="fl">' +
                        '<img class="photo" alt="'+nome+'\'s Picture" title="'+nome+' Avatar" src="'+foto+'" width="45" height="45" />' +
                      '</a>' +
                      creator+
                      //fav+
    			(!w.retweeted_status ? '<a class="tweets_names usuario" title="'+user+'" nohref="'+tURL(user)+'" onclick="ShowUser(\''+user+'\')">'+user+'</a>: ':'')+
                      '<span id="texto_'+tid+'" class="texwt" data="'+classic_txt+'">'+txt+'</span>' +
                  '</div>' +
                  '<div class="cinza">' +
                      '<span><a title="'+tid+'" class="cinza p8 tweetdata" href="'+tURL(user+'/status/'+tid)+'" target="_blank" data="'+data+'">'+TweetData(data)+'</a></span>' +
                      (time == 'messages' ? '' : ' via '+source+' ') +
                      in_reply +
                      Retweeted +
                      '<span class="fr">'+Traduz(time)+'</span>' +
                  '</div><br />' +
              '</div>' +
      '</div><br />';
    return r;
}

/*
 *  Utils.UI.Notifications
*/
Utils.UI.Notifications = function(w, time)
{
    if(time == 'messages'){
        var user = w.sender.screen_name,
        tid = w.id,
        nome = w.sender.name,
        classic_txt = '';
        txt =  w.text,
        foto = w.sender.profile_image_url,
        data = '<span class="data">'+TweetData(w.created_at)+'</span>',
        from = '',
        source = '';
    }else{
        var user = w.user.screen_name,
        tid = w.id,
        nome = w.user.name,
        classic_txt = w.retweeted_status ? w.text : '';
        txt = w.retweeted_status ? 'RT @'+w.retweeted_status.user.screen_name+': '+w.retweeted_status.text : w.text,
        foto = w.user.profile_image_url,
        data = '<a href="'+tURL(user+'/status/'+tid)+'" target="_blank" class="data">'+TweetData(w.created_at)+'</a>',
        from = Traduz('from'),
        source = w.source;
    }

    source = source.replace('rel=\"nofollow\"', 'class="data" target="_blank"');

    txt = Utils.Regex.Replace(txt, true);

    var in_reply = w.in_reply_to_status_id ? '<a class="data" href="'+tURL(w.in_reply_to_screen_name+'/status/'+w.in_reply_to_status_id)+'" target="_blank" title="'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'">'+Traduz('in_reply_to')+' '+w.in_reply_to_screen_name+'</a>' : '';
    var GEO = Utils.Tweet.GetGeo(w, tid, time, true);
    var Timeout = s(config.desktop_notifications_timeout);

    var Lay =
        '<scr'+'ipt>Timeout = '+Timeout+';</scr'+'ipt>'+
        '<div class="tweet">'+
            '<a title="'+nome+'" href="'+tURL(user)+'" target="_blank" class="nome">'+
                '<img class="foto fl" src="'+foto+'" width="45" height="45" />'+
                user+
            '</a>'+
            '<div class="texto">'+
                txt+
            '</div>'+
            '<div class="cb">'+
                '<span class="fl">'+
                    GEO+
                    data+
                    '<span class="data"> '+from+' </span>'+
                    '<a class="data">'+source+'</a>'+
                '</span>'+
                '<span class="data fr">'+(Traduz(time).capitalize())+'</span>'+
            '</div>'+
            '<br />'+
        '</div>'
    ;
    return Lay;
}